package com.jtjrenren.android.taxi.passenger.core.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.jtjrenren.android.taxi.passenger.R;
import com.jtjrenren.android.taxi.passenger.bean.api.ApiJdList;
import com.jtjrenren.android.taxi.passenger.base.BaseRcyAdapter;

/**
 * Created by Administrator on 2016/1/29.
 */
public class JindouHistoryAdapter extends BaseRcyAdapter<ApiJdList.RecordListEntity> {

    public JindouHistoryAdapter(Context context) {
        super(context);
    }

    @Override
    public RecyclerView.ViewHolder getItemViewHolder(ViewGroup parent, int viewType) {
        View view = inflater.inflate(R.layout.item_jindouhistory, parent, false);
        return new RecordViewHolder(view);
    }

    @Override
    public void onBindItemViewHolder(RecyclerView.ViewHolder holder, int position) {
        RecordViewHolder viewHolder= (RecordViewHolder) holder;

        ApiJdList.RecordListEntity info=list.get(position);
        viewHolder.tv_desc.setText(info.getMaterialName());
        viewHolder.tv_date.setText(info.getExchangeTime());
        if (info.getKingtouAmount().indexOf("-")>-1){
            viewHolder.tv_count.setTextColor(context.getResources().getColor(R.color.app_red));
            viewHolder.tv_count.setText(info.getKingtouAmount());
        }else {
            viewHolder.tv_count.setTextColor(context.getResources().getColor(R.color.label_green));
            viewHolder.tv_count.setText("+"+info.getKingtouAmount());
        }
    }

    public class RecordViewHolder extends RecyclerView.ViewHolder {
        TextView tv_desc, tv_date, tv_count;

        public RecordViewHolder(View itemView) {
            super(itemView);

            tv_desc= (TextView) itemView.findViewById(R.id.item_jindouhistory_desc);
            tv_count= (TextView) itemView.findViewById(R.id.item_jindouhistory_count);
            tv_date= (TextView) itemView.findViewById(R.id.item_jindouhistory_date);
        }
    }
}
